<template>
  <div class="app-container">
    <basic-container v-show="showSearch">
      <common-search @handleQuery="handleQuery" @resetQuery="resetQuery">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" size="mini">
          <el-form-item label="批次号" prop="voyageNo">
            <el-input
              v-model="queryParams.voyageNo"
              placeholder="请输入运输工具航次号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="提单号" prop="billNo">
            <el-input
              v-model="queryParams.billNo"
              placeholder="请输入提运单号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        <el-form-item label="进出口" prop="iEFlag">
          <el-input
            v-model="queryParams.iEFlag"
            placeholder="请输入进出口标志"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

          <el-form-item label="核销状态" prop="ncavStatus">
            <el-select v-model="queryParams.ncavStatus" placeholder="请选择核销状态,0:未核销,1:核销" clearable>
              <el-option label="请选择字典生成" value="" />
            </el-select>
          </el-form-item>
        </el-form>
      </common-search>
    </basic-container>

    <basic-container>
      <el-row :gutter="10" class="mb8">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
      <el-table v-loading="loading" :data="gLedgerHeadList" @selection-change="handleSelectionChange" @row-dblclick="showDetail"  stripe border size="small">
        <el-empty slot="empty" :image="require('@/assets/images/empty.png')" :image-size="260"></el-empty>
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="批次号" prop="voyageNo" min-width="150" show-overflow-tooltip/>
        <el-table-column label="提运单号" prop="billNo" min-width="180" show-overflow-tooltip/>
        <el-table-column label="商品分类" align="center" prop="goodsClassify" />
        <el-table-column label="商品名" align="center" prop="goodsName" />
        <el-table-column label="进出口标志" align="center" prop="iEFlag" min-width="90">
          <template slot-scope="scope">
              <dict-tag :options="dict.type.sys_i_e_flag" :value="scope.row.iEFlag" />
            </template>
          </el-table-column>
        <el-table-column label="舱单重量" align="center" prop="totalManifestWt" min-width="100" show-overflow-tooltip/>
        <el-table-column label="舱单件数" align="center" prop="packNo" />
        <el-table-column label="场内重量" align="center" prop="fieldGrossWt" />
        <el-table-column label="预扣数量" align="center" prop="preNcavPackNo" />
        <el-table-column label="预扣重量" align="center" prop="preNcavWt" />
        <el-table-column label="实扣数量" align="center" prop="ncavPackNo" />
        <el-table-column label="实扣重量" align="center" prop="ncavWt" />
        <el-table-column label="核销状态" align="center" prop="ncavStatus">
        <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_bill_status" :value="scope.row.ncavStatus" />
          </template>
        </el-table-column>
        <el-table-column label="海关编号" align="center" prop="customsNo" />
        <el-table-column label="场站名称" align="center" prop="fieldName" min-width="150" show-overflow-tooltip/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180"> </el-table-column>
      <el-table-column label="数据状态" align="center" prop="mftDel" width="180">
        <template slot-scope="scope">
            <dict-tag :options="dict.type.gLedger_del_mark" :value="scope.row.mftDel" />
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" min-width="100">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="showDetail(scope.row)"
              v-hasPermi="['system:gLedgerHead:query']"
            >详情</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </basic-container>


    <!-- 详情dialog-->
    <el-dialog :visible.sync="detailOpen" width="50%" append-to-body :close-on-click-modal="false">
       <el-descriptions class="margin-top" title="公路运输底账详情" :column="3"  border>
		<el-descriptions-item>
		       <template slot="label">
		        批次号
		       </template>
		      {{form.voyageNo}}
		 </el-descriptions-item>
 <el-descriptions-item>
		        <template slot="label">
		         提运单号
		        </template>
		       {{form.billNo}}
		  </el-descriptions-item>
     <el-descriptions-item>
		        <template slot="label">
		         进出口标志
		        </template>
		       {{form.iEFlag}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         海关编号
		        </template>
		       {{form.customsNo}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         经营单位名称
		        </template>
		       {{form.tradeName}}
		  </el-descriptions-item>

		 <el-descriptions-item>
		        <template slot="label">
		         核销状态
		        </template>
		       {{form.ncavStatus}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         舱单重量
		        </template>
		       {{form.releasGrossWt}}
		  </el-descriptions-item>
 <el-descriptions-item>
		        <template slot="label">
		         理货数量
		        </template>
		       {{form.packNo}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         理货重量
		        </template>
		       {{form.grossWt}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         场站编码
		        </template>
		       {{form.fieldCode}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         场站名称
		        </template>
		       {{form.fieldName}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         场内重量
		        </template>
		       {{form.fieldGrossWt}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         商品名
		        </template>
		       {{form.goodsName}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         舱单总重量
		        </template>
		       {{form.totalManifestWt}}
		  </el-descriptions-item>

		 <el-descriptions-item>
		        <template slot="label">
		         预扣数量
		        </template>
		       {{form.preNcavPackNo}}
		  </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         实扣重量
		        </template>
		       {{form.ncavWt}}
		  </el-descriptions-item>
      <el-descriptions-item>
             <template slot="label">
             实扣数量
             </template>
            {{form.ncavPackNo}}
       </el-descriptions-item>
      <el-descriptions-item>
             <template slot="label">
              预扣重量
             </template>
            {{form.preNcavWt}}
       </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         进场重量
		        </template>
		       {{form.inWt}}
		  </el-descriptions-item>
      <el-descriptions-item>
             <template slot="label">
              进场所时间
             </template>
            {{form.inDate}}
       </el-descriptions-item>
		 <el-descriptions-item>
		        <template slot="label">
		         出场重量
		        </template>
		       {{form.outWt}}
		  </el-descriptions-item>
      <el-descriptions-item>
             <template slot="label">
              出场所时间
             </template>
            {{form.outDate}}
       </el-descriptions-item>
     <el-descriptions-item>
            <template slot="label">
             创建时间
            </template>
           {{form.createTime}}
      </el-descriptions-item>
         </el-descriptions>
        <div slot="footer" class="dialog-footer" style="text-align: center;">
          <el-button @click="closeDetail">关闭</el-button>
        </div>
    </el-dialog>
  </div>
</template>

<script>
import { listGLedgerHead, getGLedgerHead} from "@/api/kmwlpts/gLedgerHead";

export default {
  name: "GLedgerHead",
  dicts:['sys_bill_status','sys_i_e_flag','gLedger_del_mark'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
       //详情显示的时候，表单编辑禁用
      isViewDisabled:false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 公路运输底账表格数据
      gLedgerHeadList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
       //显示详情
      detailOpen:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        iEFlag: null,
        customsNo: null,
        billNo: null,
        parentBillNo: null,
        tradeCo: null,
        tradeName: null,
        packNo: null,
        grossWt: null,
        monitorFlag: null,
        ncavStatus: null,
        releasGrossWt: null,
        releasPackNo: null,
        contaCount: null,
        ncavContaCount: null,
        preNcavContaCount: null,
        voyageNo: null,
        fieldCode: null,
        fieldName: null,
        versionStamp: null,
        releasContaCount: null,
        syncDate: null,
        fieldGrossWt: null,
        status: null,
        formId: null,
        formType: null,
        goodsName: null,
        inDate: null,
        outDate: null,
        billCode: null,
        entryDate: null,
        inType: null,
        manifestId: null,
        totalManifestWt: null,
        syncStatus: null,
        inAreaWay: null,
        outAreaWay: null,
        mftDel: null,
        mftDelDate: null,
        preNcavPackNo: null,
        preNcavWt: null,
        ncavPackNo: null,
        ncavWt: null,
        inWt: null,
        outWt: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询公路运输底账列表 */
    getList() {
      this.loading = true;
      listGLedgerHead(this.queryParams).then(response => {
        this.gLedgerHeadList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        ledgerid: null,
        iEFlag: null,
        customsNo: null,
        billNo: null,
        parentBillNo: null,
        tradeCo: null,
        tradeName: null,
        packNo: null,
        grossWt: null,
        monitorFlag: null,
        ncavStatus: 0,
        releasGrossWt: null,
        releasPackNo: null,
        contaCount: null,
        ncavContaCount: null,
        preNcavContaCount: null,
        voyageNo: null,
        fieldCode: null,
        fieldName: null,
        versionStamp: null,
        releasContaCount: null,
        syncDate: null,
        fieldGrossWt: null,
        status: "0",
        formId: null,
        formType: null,
        goodsName: null,
        inDate: null,
        outDate: null,
        billCode: null,
        entryDate: null,
        inType: null,
        manifestId: null,
        totalManifestWt: null,
        syncStatus: "0",
        inAreaWay: null,
        outAreaWay: null,
        mftDel: null,
        mftDelDate: null,
        preNcavPackNo: null,
        preNcavWt: null,
        ncavPackNo: null,
        ncavWt: null,
        inWt: null,
        outWt: null,
        createTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.ledgerid)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    //关闭详情
    closeDetail(){
      this.detailOpen=false;
    },
     //显示详情
    showDetail(row, column, event){
        this.reset();
        //关闭表单编辑模式
        this.isViewDisabled=true;
        const ledgerid = row.ledgerid;
        this.load(ledgerid);
          //打开详情
        this.detailOpen=true;
    },
     /** 加载数据 */
    load(ledgerid){
	    getGLedgerHead(ledgerid).then(response => {
          this.form = response.data;
       });
	},
  }
};
</script>
